<h1>
    <? if(!$this->post): ?>
    <?= $this->partial('user/navigation4user.phtml')?>
    <? endif ?>
    <? $style = !($this->post) ? 'style="display: none;"' : null ?>
    <div id="form-charge" <?= $style ?>>
        <?= $this->form ?>
    </div><br>
</h1>
<?
$orders = $this->orders;
$user = $this->user;
?>

<h1>Your money: <span style="color:orange; font-size: 20px;"><?= $user['money'] ?> piastres</span></h1>

<? if (!count($orders)): ?>
<h2 style="padding-top: 30px;">You don't have maps. Please treasure maps <a href="/map/maps">here</a>.</h2>
<? endif; ?>

<? foreach ($orders as $order): ?>


<div style="float: right; padding: 30px 30px 25px 40px ">
    <a href="view/<?=$order['map']['id']?>"> <img width="240px" src="<?=$order['map']['url']?>"
                                                  alt="<?=$this->escape($order['map']['title'])?>">
    </a></div>
<!--    --><? //print '<pre>';
    //    print_r($order);
    //    print '</pre>';
    //    die;
    ?>
<div>


    <div style="text-align:center; font-weight: bold;"><p><?= $this->escape($order['map']['title']) ?></p></div>
    <div><p><?= $order['map']['description'] ?></p></div>

    <div style="clear: both;"></div>
    <div style="text-align: center;">
        <?
        $now = strtotime('now');
        $start_diff = $now - strtotime(date_format($order['map']['datestart'], "Y-m-d"));
        $end_diff = $now - strtotime(date_format($order['map']['dateend'], "Y-m-d"));
        ?>
        <? if ($start_diff >= 0) : ?>
        <? if ($end_diff > 0): ?>
                This map is not available more.
            <? else: ?>
           <br>
           <a href="<?=$order['map']['file']?>" style="padding-right: 30px">Download map</a> <a style="padding-left: 30px" href="<?= $this->url(array('id' => $order['map']['id']), 'solve') ?>">Report a trove</a>
            <? endif; ?>
        <? else: ?>
        <p> This map will be available on:  <?= date_format($order['map']['datestart'], "m.d.y");?></p>
        <? endif; ?>
    </div>

    <div style="clear: both;"></div>

</div>



<? endforeach; ?>
